<?php


namespace App\Admin\Actions\Review;


use App\Admin\Actions\RowAction;
use Illuminate\Http\Request;

class AdminReview extends RowAction
{
    public $name = '审批';

    public function handle($model, Request $request)
    {
        $status = $request->get('status');
        $remark = $request->get('remark');
        try {
            $model->review_status = $status;
            $model->review_remark = $remark;
            $model->save();
        } catch (\Exception $exception) {
            return $this->response()->error('审核失败！')->refresh();
        }
        return $this->response()->success('审核成功！')->location('');
    }

    public function form()
    {
        $this->radio('status', '请选择审核状态')
            ->options([1 => '通过', 2 => '不通过'])
            ->required();
        $this->textarea('remark', '备注');
    }

}
